<template>
    <div class="detail-box">
        <!-- 详情页轮播图 -->
        <!-- Swiper -->
        <div class="swiper-container">
            <div class="swiper-wrapper">
                <div class="swiper-slide" 
                    :style="`background-image:url(${product.img})`"
                    v-for="(v,i) in 5" :key="i"
                ></div>
            </div>
            <!-- Add Pagination -->
            <div class="swiper-pagination"></div>
        </div>
        <!-- 悬浮退出、购物车展示 -->
        <div class="detail-float">
            <div class="detail-float-left" @click="$router.back()">
                <i class="iconfont icon-left"></i>
            </div>
            <div class="detail-float-right">
                <router-link to="/cart" tag="i" class="iconfont icon-cart"></router-link>
                <!-- <i class="iconfont icon-cart"></i> -->
            </div>
        </div>
        <!-- 价格、说明 介绍 展示 -->
        <div class="detail-price">
            <div>
                <span>￥{{product.price}}</span>
                <span>￥{{product.orgPrice}}</span>
            </div>
            <p>{{product.title}}</p>
            <span>免运费</span>
        </div>
        <!-- 下划线 -->
        <hr style="height:0.3rem;border:none;background-color:rgba(0,0,0,0.1);">
        <!-- 优惠领券等 展示 -->
        <div class="detail-favourable">
            <div class="detail-favourable-top">
                <div>优惠</div>
                <div class="detail-favourable-top-center">
                    <p>领券后，下单至少可减
                    </p>
                    <span>3元</span>
                    <div>
                        <p>店铺优惠券</p>
                        <p>满98减3</p>
                        <p>满198减10</p>
                    </div>
                </div>
                <div>领券 ></div>
            </div>
            <div class="detail-favourable-bottom">
                <div>促销</div>
                <div>
                    <p>满折</p>
                    <span>满3件打9.5折，满99件打8.5折</span>
                </div>
                <div>更多 ></div>
            </div>
        </div>
        <!-- 发货退货等展示 -->
        <div class="detail-delivery">
            <p><i class="iconfont icon-success"></i>72小时发货</p>
            <p><i class="iconfont icon-success"></i>7天无理由退货</p>
            <p><i class="iconfont icon-success"></i>退货补运费</p>
        </div>
        <!-- 下划线 -->
        <hr style="height:0.3rem;border:none;background-color:rgba(0,0,0,0.1);">
        <!-- 买家评价展示 -->
        <div class="detail-appraisal">
            <span>买家评价333</span>
            <span>更多 ></span>
        </div>
        <!-- 关于各类评价的标签的展示 -->
        <div class="detail-label">
            <p>全部(333)</p><p>最新(0)</p><p>有图片(200)</p><p>款式好(61)</p>
            <p>颜色正(51)</p><p>卖家服务很好(21)</p><p>性价比高(20)</p><p>包装很赞(15)</p>
            <p>礼物很喜欢(11)</p><p>整体感觉不错(11)</p><p>物流快(10)</p><p>质量很好(5)</p>
            <p>发货速度快(5)</p><p>料子很不错(3)</p><p>颜色一般(7)</p><p>有异味(5)</p>
            <p>物流有点慢(5)</p><p>质量一般(3)</p>
        </div>
        <!-- 买家具体评论展示 -->
        <DetailBar></DetailBar>
        <!-- 详情底部栏 -->
        <!-- <DetailBottomBar></DetailBottomBar> -->
    </div>
</template>
<script>
import DetailBar from "../components/detailBar";
// import DetailBottomBar from "../components/detailBottomBar";
import {mapState,mapActions} from "vuex";
export default {
    components:{
        DetailBar,
        // DetailBottomBar
    },
    computed: {
        ...mapState(["detail"])
    },
    data(){
        return {
            product:{}
        }
    },
    methods:{
        ...mapActions(["loadProductDetail"]),
        loadProduct(){
            this.product=JSON.parse(localStorage.getItem(this.$route.query.tradeItemId));
        }
    },
    mounted() {
        //头部轮播图js代码
        var swiper = new Swiper(".swiper-container", {
            effect: "coverflow",
            grabCursor: true,
            centeredSlides: true,
            slidesPerView: "auto",
            coverflowEffect: {
                rotate: 45,
                stretch: 0,
                depth: 200,
                modifier: 1,
                slideShadows: true
            },
            pagination: {
                el: ".swiper-pagination"
            }
        });
        this.loadProductDetail(this.$route.query.tradeItemId);
        this.loadProduct();
    }
};
</script>
<style lang="less" scoped>
//详情页样式
.detail-box {
    position: absolute;
    top: 0rem;
    bottom: 1rem;
    left: 0rem;
    right: 0rem;
    overflow-y: auto;
}
//头部轮播图样式
.swiper-container {
    width: 100%;
    // padding-top: 1rem;
    padding-bottom: 1rem;
    .swiper-slide {
        background-position: center;
        background-size: cover;
        width: 600px;
        height: 600px;
    }
}
//悬浮退出、购物车的样式
.detail-float {
    position: absolute;
    top: 0rem;
    z-index: 100;
    width: 100%;
    height: 1rem;
    box-sizing: border-box;
    padding: 0.2rem;
    overflow: hidden;
    > .detail-float-left {
        width: 0.7rem;
        height: 0.7rem;
        border-radius: 50%;
        background-color: rgba(0, 0, 0, 0.5);
        float: left;
        text-align: center;
        line-height: 0.7rem;
        color: @white;
    }
    > .detail-float-right {
        width: 0.7rem;
        height: 0.7rem;
        border-radius: 50%;
        background-color: rgba(0, 0, 0, 0.5);
        float: right;
        text-align: center;
        line-height: 0.7rem;
        color: @white;
    }
}
//价格、说明、介绍的样式
.detail-price {
    width: 100%;
    box-sizing: border-box;
    padding: 0.2rem;
    > div {
        padding-bottom:0.1rem;
        > span:first-child {
            font-size: 0.4rem;
            font-weight: bold;
        }
        > span:last-child {
            padding-left: 0.3rem;
            font-size: 0.2rem;
            text-decoration: line-through;
            color: @gray;
        }
    }
    > p {
        text-indent: 0.4rem;
        overflow:hidden;
        display:-webkit-box;
        -webkit-box-orient:vertical;
        -webkit-line-clamp:2;
        text-overflow:ellipsis;
        margin-bottom:0.1rem;
    }
    >span{
        font-size:0.2rem;
        color:@gray;
    }
}
//优惠券等的样式
.detail-favourable{
    width:100%;
    border-bottom:1px solid @gray;
    >.detail-favourable-top{
        width:100%;
        display:flex;
        padding:0.2rem;
        box-sizing:border-box;
        >div:first-child{
            flex:1;
            color:@gray;
            font-size:0.28rem;
        }
        >.detail-favourable-top-center{
            flex:5;
            display:flex;
            flex-flow:row wrap;
            padding-left:0.2rem;
            >p{
                font-size:0.28rem;
            }
            >span{
                color:@pink;
                font-size:0.28rem;
            }
            >div{
                width:100%;
                display:flex;
                font-size:0.28rem;
                justify-content:space-between;
                padding-top:0.2rem;
                >p{
                    background-color:@gray-light;
                    color:@pink;
                    border-radius:50% 50%;
                    padding:0rem 0.15rem;
                }
            }
        }
        >div:last-child{
            flex:1;
            color:@gray;
            font-size:0.28rem;
        }
    }
    >.detail-favourable-bottom{
        width:100%;
        display:flex;
        padding:0.2rem;
        box-sizing:border-box;
        >div:first-child{
            flex:1;
            color:@gray;
            font-size:0.28rem;
        }
        >div:nth-child(2){
            flex:5;
            display:flex;
            flex-flow:row wrap;
            padding-left:0.2rem;
            box-sizing:border-box;
            >p{
                font-size:0.28rem;
                color:@pink;
                background-color:@gray-light;
                border-radius:50% 50%;
                padding:0rem 0.15rem;
            }
            >span{
                padding-left:0.15rem;
                font-size:0.28rem
            }
        }
        >div:last-child{
            flex:1;
            color:@gray;
            font-size:0.28rem;
        }
    }
}
//发货、退货说明的样式
.detail-delivery{
    width:100%;
    box-sizing:border-box;
    padding:0.2rem;
    display:flex;
    justify-content:space-around;
    >p{
        font-size:0.28rem;
        >i{
            color:@pink;
        }
    }
}
//买家评论的样式
.detail-appraisal{
    width:100%;
    box-sizing:border-box;
    padding:0.2rem;
    overflow:hidden;
    >span{
        color:@gray;
        font-size:0.28rem;
    }
    >span:last-child{
        float:right;
        padding-right:0.12rem;
    }
}
//各类评价标签的样式
.detail-label{
    width:100%;
    box-sizing:border-box;
    padding:0rem 0.2rem;
    display:flex;
    flex-flow:row wrap;
    >p{
        background-color:@gray-light;
        color:@pink;
        padding:0.1rem;
        margin:0.2rem 0.1rem 0rem 0.1rem;
        font-size:0.28rem;
    }
}
</style>